package com.lp.biz.operations.controller;

import com.lp.biz.operations.model.query.BlackListQuery;
import com.lp.biz.operations.service.OperationsService;
import com.lp.common.annotation.PermissionAnnotation;
import com.lp.common.entity.PageParams;
import com.lp.common.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.lp.common.constant.MenuConstant.*;

/**
 * @program: backend
 * @description:
 * @author: Ke.Song
 * @since: 2024-06-26 20:16:11
 */
@RestController
@RequestMapping("/operations")
public class OperationsController {

    @Autowired
    private OperationsService operationsService;

    /**
     * 获取黑名单列表
     * @param query 查询参数
     * @return 查询结果
     */
    @GetMapping("/blacklist")
    @PermissionAnnotation(menus = {BLACK_LIST})
    public CommonResult getBlackList(BlackListQuery query) {
        return operationsService.getBlackList(query);
    }

    /**
     * 发票列表
     * @param query 查询参数
     * @return 查询结果
     */
    @GetMapping("/invoice")
    @PermissionAnnotation(menus = {INVOICE_MANAGE})
    public CommonResult invoiceList(PageParams query) {
        return operationsService.invoiceList(query);
    }

    /**
     * 变更发票发送状态
     * @param invoiceId 发票Id
     * @return 处理结果
     */
    @PutMapping("/invoice/{invoiceId}")
    @PermissionAnnotation(menus = {INVOICE_MANAGE})
    public CommonResult updateInvoiceStatus(@PathVariable Integer invoiceId) {
        operationsService.updateInvoiceStatus(invoiceId);
        return CommonResult.success();
    }
}
